<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    {include file="common/head" /}
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form action="" id="form" class="layui-form" method="post">
            <input type="hidden" name="uid" value="{$info.uid|default=0}">

            <div class="layui-form-item">
                <label for="mobile" class="layui-form-label">
                    <span class="x-red">*</span>手机号
                </label>
                <div class="layui-input-inline">
                    <input type="text" value="{$info.mobile}" id="mobile" name="mobile" required=""
                           lay-verify="mobile" autocomplete="off" class="layui-input">

                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名
                </div>
            </div>

            {:getFundImg($info['head_pic'],'head_pic','头像')}

            {if empty($info['uid'])}
            <div class="layui-form-item">
                <label for="password" class="layui-form-label">
                    <span class="x-red">*</span>密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" value="{$info.password}" id="password" name="password" required=""
                           lay-verify="pwd" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">

                </div>
            </div>
            {/if}

            <div class="layui-form-item">
                <label for="distribut_money" class="layui-form-label">
                    <span class="x-red"></span>佣金余额
                </label>
                <div class="layui-input-inline">
                    <input type="number" value="{$info.distribut_money|default=0}" id="distribut_money" name="distribut_money" autocomplete="off" class="layui-input">

                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red"></span>状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="1" {eq name="info['status']" value="1" }checked{/eq}
                    lay-skin="primary" title="正常" checked="">
                    <input type="radio" name="status" value="0" {eq name="info['status']" value="0" }checked{/eq}
                    lay-skin="primary" title="禁用">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="ok" class="layui-form-label">
                </label>
                <button id="ok" class="layui-btn" lay-filter="add" lay-submit="">
                    {empty name="info['uid']"}
                    增 加
                    {else /}
                    修 改
                    {/empty}

                </button>
            </div>
        </form>
    </div>
</div>

<div id="idbox" style="display: none">

</div>
<script>layui.use(['form', 'layer'],
    function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //自定义验证规则
        form.verify({
            mobile: function (value) {
                if (!new RegExp("^1[3456789]\\d{9}$").test(value)) {
                    return '请填写正确的手机号';
                }
            },

            pwd: function (value) {
                if (value.len<6) {
                    return '密码请设置6位以上的字符';
                }
            }
        });

        //监听提交
        form.on('submit(add)',
            function (data) {
                $.ajax({
                    type: "POST",
                    url: "{:url()}",
                    data: data.field,
                    success: function (result) {

                        if(result.code){
                            layer.alert(result.msg, {
                                icon: 6
                            }, function () {
                                xadmin.close();
                            });
                        }else{
                            layer.alert(result.msg,{
                                icon: 2
                            });
                        }

                    },
                    error: function (result) {
                        layer.alert(result.msg, {
                            icon: 2
                        }, function () {
                            xadmin.close();
                        });
                    }

                });
                return false;
            });


    });
</script>

</body>

</html>
